def is_brackets_valid(brackets):
    # 如果为奇数，必然为FALSE
    if len(brackets) % 2 != 0:
        return False

    bracket_dict = {')':'(',  ']':'[', '}':'{'}
    stack = []
    for s in brackets:
        if s in {'(', '[', '{'}:
            stack.append(s)  # 凡是左括号无脑入栈
        else:
            if stack and bracket_dict.get(s) == stack[-1]:
                stack.pop()
            else:
                return False

    return not stack  


if __name__ == "__main__":
    brackets = '([]){}'
    print(is_brackets_valid(brackets))
